import BaseMapper from "./BaseMapper";
import SqlStatement from "../sql/SqlStatement";
import SystemMember from "../entity/SystemMember";
import SystemGlobal from "../entity/SystemGlobal";

export default class SystemGlobalMapper implements BaseMapper<SystemGlobal> {
    async deleteById(statement: SqlStatement) {
        return await statement.run();
    }

    async insert(statement: SqlStatement) {
        return await statement.run();
    }

    async page(statement: SqlStatement) {
        const rows = await statement.all();
        const total = await statement.count();
        return {
            rows,
            total: total.counter
        }
    }

    async updateById(statement: SqlStatement) {
        return await statement.run();
    }

    async selectByDefault(mobile: string) {
        const sql = `SELECT * FROM system_global limit 1 offset 0`;
        const statement = new SqlStatement(sql);
        const one = await statement.get();
        return one;
    }
}
